package ch4;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

@WebServlet(name = "TestServlet06",urlPatterns = "/test06")
public class TestServlet06 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletContext servletContext=this.getServletContext();
        String path=servletContext.getRealPath("/aaa/dbinfo.properties");
        System.out.println(path);
        FileInputStream in=new FileInputStream(path);
        Properties properties=new Properties();
        properties.load(in);
        System.out.println(properties.getProperty("name"));
        System.out.println(properties.getProperty("password"));
    }
}
